package com.uniflow.entity;

import com.fasterxml.jackson.annotation.JsonFormat;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 流程定义实体
 */
public class ProcessDefinition {
    
    private String id;
    private String key;
    private String name;
    private String description;
    private Integer version;
    private String category;
    private String deploymentId;
    private String resourceName;
    private String diagramResourceName;
    private boolean suspended;
    private String tenantId;
    private String formKey;
    private boolean hasStartFormKey;
    private boolean hasGraphicalNotation;
    
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime deploymentTime;
    
    // 扩展字段
    private String xmlContent; // BPMN XML内容
    private String jsonContent; // 流程JSON配置
    private List<ProcessVariable> variables; // 流程变量
    private List<ProcessNode> nodes; // 流程节点
    
    // 构造函数
    public ProcessDefinition() {}
    
    public ProcessDefinition(String id, String key, String name) {
        this.id = id;
        this.key = key;
        this.name = name;
    }
    
    // Getters and Setters
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public String getKey() {
        return key;
    }
    
    public void setKey(String key) {
        this.key = key;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public Integer getVersion() {
        return version;
    }
    
    public void setVersion(Integer version) {
        this.version = version;
    }
    
    public String getCategory() {
        return category;
    }
    
    public void setCategory(String category) {
        this.category = category;
    }
    
    public String getDeploymentId() {
        return deploymentId;
    }
    
    public void setDeploymentId(String deploymentId) {
        this.deploymentId = deploymentId;
    }
    
    public String getResourceName() {
        return resourceName;
    }
    
    public void setResourceName(String resourceName) {
        this.resourceName = resourceName;
    }
    
    public String getDiagramResourceName() {
        return diagramResourceName;
    }
    
    public void setDiagramResourceName(String diagramResourceName) {
        this.diagramResourceName = diagramResourceName;
    }
    
    public boolean isSuspended() {
        return suspended;
    }
    
    public void setSuspended(boolean suspended) {
        this.suspended = suspended;
    }
    
    public String getTenantId() {
        return tenantId;
    }
    
    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }
    
    public String getFormKey() {
        return formKey;
    }
    
    public void setFormKey(String formKey) {
        this.formKey = formKey;
    }
    
    public boolean isHasStartFormKey() {
        return hasStartFormKey;
    }
    
    public void setHasStartFormKey(boolean hasStartFormKey) {
        this.hasStartFormKey = hasStartFormKey;
    }
    
    public boolean isHasGraphicalNotation() {
        return hasGraphicalNotation;
    }
    
    public void setHasGraphicalNotation(boolean hasGraphicalNotation) {
        this.hasGraphicalNotation = hasGraphicalNotation;
    }
    
    public LocalDateTime getDeploymentTime() {
        return deploymentTime;
    }
    
    public void setDeploymentTime(LocalDateTime deploymentTime) {
        this.deploymentTime = deploymentTime;
    }
    
    public String getXmlContent() {
        return xmlContent;
    }
    
    public void setXmlContent(String xmlContent) {
        this.xmlContent = xmlContent;
    }
    
    public String getJsonContent() {
        return jsonContent;
    }
    
    public void setJsonContent(String jsonContent) {
        this.jsonContent = jsonContent;
    }
    
    public List<ProcessVariable> getVariables() {
        return variables;
    }
    
    public void setVariables(List<ProcessVariable> variables) {
        this.variables = variables;
    }
    
    public List<ProcessNode> getNodes() {
        return nodes;
    }
    
    public void setNodes(List<ProcessNode> nodes) {
        this.nodes = nodes;
    }
    
    @Override
    public String toString() {
        return "ProcessDefinition{" +
                "id='" + id + '\'' +
                ", key='" + key + '\'' +
                ", name='" + name + '\'' +
                ", version=" + version +
                ", suspended=" + suspended +
                '}';
    }
    
    // 内部类：流程变量
    public static class ProcessVariable {
        private String name;
        private String type;
        private Object value;
        private String description;
        private boolean required;
        
        // 构造函数
        public ProcessVariable() {}
        
        public ProcessVariable(String name, String type, Object value) {
            this.name = name;
            this.type = type;
            this.value = value;
        }
        
        // Getters and Setters
        public String getName() { return name; }
        public void setName(String name) { this.name = name; }
        public String getType() { return type; }
        public void setType(String type) { this.type = type; }
        public Object getValue() { return value; }
        public void setValue(Object value) { this.value = value; }
        public String getDescription() { return description; }
        public void setDescription(String description) { this.description = description; }
        public boolean isRequired() { return required; }
        public void setRequired(boolean required) { this.required = required; }
    }
    
    // 内部类：流程节点
    public static class ProcessNode {
        private String id;
        private String name;
        private String type;
        private String assignee;
        private String candidateUsers;
        private String candidateGroups;
        private String formKey;
        private String documentation;
        
        // 构造函数
        public ProcessNode() {}
        
        public ProcessNode(String id, String name, String type) {
            this.id = id;
            this.name = name;
            this.type = type;
        }
        
        // Getters and Setters
        public String getId() { return id; }
        public void setId(String id) { this.id = id; }
        public String getName() { return name; }
        public void setName(String name) { this.name = name; }
        public String getType() { return type; }
        public void setType(String type) { this.type = type; }
        public String getAssignee() { return assignee; }
        public void setAssignee(String assignee) { this.assignee = assignee; }
        public String getCandidateUsers() { return candidateUsers; }
        public void setCandidateUsers(String candidateUsers) { this.candidateUsers = candidateUsers; }
        public String getCandidateGroups() { return candidateGroups; }
        public void setCandidateGroups(String candidateGroups) { this.candidateGroups = candidateGroups; }
        public String getFormKey() { return formKey; }
        public void setFormKey(String formKey) { this.formKey = formKey; }
        public String getDocumentation() { return documentation; }
        public void setDocumentation(String documentation) { this.documentation = documentation; }
    }
}